<?php

class fModulesRenderHelper {
	public static function renderModule($name, $params, $path = null) {
		if ($path == null) {
			$path = _APP_PATH_.'modules'._DS_;				
		}
		if (!file_exists($file = $path.$name._DS_.$name.'.module.php'))
			throw new fControllerException('Not found module file ' . $name);
		require_once $file;
		
		$module = new $name();
		if (fConfig::get('debug')) {
			fProfiler::getInstance()->mark('render module "' . $name .'"', 'system.'.get_class($this));
		}
		return $module->render();
	}
}